package com.kystar.muxplayer.protocol.connection;

import com.kystar.muxplayer.base.TLog;
import com.kystar.muxplayer.protocol.CodeCmd;
import com.kystar.muxplayer.protocol.Connection;
import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class LogConnection implements Connection {

    private final Connection mConnection;

    public LogConnection(Connection connection) {
        mConnection = connection;
    }

    @Override
    public void close() {
        TLog.e("connection","close");
        mConnection.close();
    }

    @Override
    public void write(CodeCmd cmd) throws IOException, TimeoutException {
        TLog.i("write",cmd.getClass().getSimpleName(),TLog.bytesToString(cmd.getValue()));
        mConnection.write(cmd);
        TLog.i("read ",cmd.getClass().getSimpleName(),TLog.bytesToString(cmd.getResult()));
    }
}
